package com.xuxin.baby.presenter;

import com.xuxin.baby.bean.BaseBean;
import com.xuxin.baby.contract.UserChildDataContract;
import com.xuxin.baby.model.UserChildDataModel;

/**
 * Created by xu_xin
 * Created on 2020/10/23 0023
 * 宝宝信息
 */
public class UserChildDataPresenter implements UserChildDataContract.Presenter {
    private final UserChildDataModel model;
    private final UserChildDataContract.View view;

    public UserChildDataPresenter(UserChildDataContract.View view) {
        this.view = view;
        model = new UserChildDataModel();
    }

    @Override
    public void addUserChild(String tenantId,
                             String token,
                             String fatherId,
                             String avatar,
                             String nickname,
                             String birthday,
                             String sex,
                             String height,
                             String weight,
                             String headCircle) {
        if (null != model) {
            model.addUserChild(this,
                    tenantId,
                    token,
                    fatherId,
                    avatar,
                    nickname,
                    birthday,
                    sex,
                    height,
                    weight,
                    headCircle);
        }
    }

    @Override
    public void updateUserChild(String tenantId, String token,
                                String childId, String fatherId,
                                String avatar, String nickname,
                                String birthday, String sex,
                                String height, String weight,
                                String headCircle) {
        if (null != model) {
            model.updateUserChild(this,
                    tenantId,
                    token,
                    childId,
                    fatherId,
                    avatar,
                    nickname,
                    birthday,
                    sex,
                    height,
                    weight,
                    headCircle);
        }
    }

    @Override
    public void deleteUserChild(String tenantId, String token, String childId) {
        if (null != model) {
            model.deleteUserChild(this,
                    tenantId,
                    token,
                    childId);
        }
    }

    @Override
    public void onSuccess(BaseBean baseBean) {
        if (null != view) {
            view.onSuccess(baseBean);
        }
    }

    /**
     * 以下内容复用(用于请求完成后的操作)
     */
    @Override
    public void onError(BaseBean baseBean) {
        if (null != view) {
            view.onError(baseBean);
        }
    }

    @Override
    public void onComplete() {
        if (null != view) {
            view.onComplete();
        }
    }
}